package uk.ac.ebi.bioinvindex.dao.ejb3;


import org.hibernate.criterion.Restrictions;
import uk.ac.ebi.bioinvindex.dao.InvestigationDao;
import uk.ac.ebi.bioinvindex.model.impl.InvestigationImpl;

import javax.persistence.EntityManager;
import java.util.List;


/**
 * User: Brandizi
 * Date: Sept 2007
 */
public class InvestigationEJB3DAO extends IdentifiableEJB3DAO<InvestigationImpl> implements InvestigationDao {
	public InvestigationEJB3DAO() {
		super();
	}

	public InvestigationEJB3DAO(EntityManager entityManager) {
		super(InvestigationImpl.class, entityManager);
	}

	public List<InvestigationImpl> findByProperty(String propertyName, Object propertyValue) {
		//ToDo: check if propertyName is a valid property
		return getSession().createCriteria(InvestigationImpl.class)
				.add(Restrictions.like(propertyName, propertyValue))
				.list();
	}

}
